home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / XLisp-Stat / Book / interpolation1.lsp < prev    next >
Lisp/Scheme  |  1990-10-11  |  812b  |  30 lines

  1. ; book pp.300-301
  2.  
  3. (require "data/stackloss")
  4.  
  5. (defun standardize (x)
  6.   (let ((x-bar (mean x))
  7.         (s (standard-deviation x)))
  8.     (/ (- x x-bar) s)))
  9.  
  10. (setf std-air (standardize air))
  11. (setf std-temp (standardize temp))
  12. (setf std-conc (standardize conc))
  13. (setf std-loss (standardize loss))
  14. (setf w (plot-points std-air std-temp))
  15. (send w :range '(0 1) -3 3)
  16. (setf indices (iseq (length std-air)))
  17.  
  18. (defun interpolate (p)
  19.   (let* ((alpha (* (/ pi 2) p))
  20.          (s (sin alpha))
  21.          (c (cos alpha))
  22.          (x (+ (* c std-air) (* s std-temp)))
  23.          (y (+ (* c std-conc) (* s std-loss))))
  24.    (send w :point-coordinate 0 indices x)
  25.    (send w :point-coordinate 1 indices y)
  26.    (send w :redraw-content)))
  27. (slider (interval-slider-dialog '(0 1) :action #'interpolate))
  28.  
  29. (send w :add-subordinate slider)
  30.